// KFrameBuffer.h: interface for the KFrameBuffer class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_KFRAMEBUFFER_H__233122FA_63A8_4AC2_9824_5205D2CCEFA5__INCLUDED_)
#define AFX_KFRAMEBUFFER_H__233122FA_63A8_4AC2_9824_5205D2CCEFA5__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "KSurface.h"

class KFrameBuffer  
{
public:
	KFrameBuffer() { m_pfZBuffer = NULL; }
	KFrameBuffer(size_t cxWidth, size_t cxHeight);
	virtual ~KFrameBuffer();

	bool Create(size_t cxWidth, size_t cxHeight);
	KSurface& GetSurface() { return m_kSurface; }

	float GetDepth(int cx, int cy) const { return m_pfZBuffer[m_kSurface.GetWidth()*cy+cx]; }
	void SetDepth(int cx, int cy, float fDepth) { m_pfZBuffer[m_kSurface.GetWidth()*cy+cx] = fDepth; }

	void Bingo(int cx, int cy) { m_pfZBuffer[m_kSurface.GetWidth()*cy+cx] += 1.0f; }
	int Count(int cx, int cy) { return (int)m_pfZBuffer[m_kSurface.GetWidth()*cy+cx]; }

private:
	KSurface m_kSurface;
	float* m_pfZBuffer;
};

#endif // !defined(AFX_KFRAMEBUFFER_H__233122FA_63A8_4AC2_9824_5205D2CCEFA5__INCLUDED_)
